'use strict';

const {
	rejects
} = require("assert");
const {
	resolve
} = require("dns");

exports.main = async (event, context) => {
	const db = uniCloud.database()
	const collection = db.collection('AccountBook')
	const aggregate = collection.aggregate()
	const $ = db.command.aggregate
	let res = await aggregate.group({
		"_id": "$OptionType",
		"list":$.push({
			'topOption': '$topOption',
			'intCount':'$intCount'
		}),
		"Total": $.sum("$intCount")
	}).end()
	return res
};